
class YaoShaiZi extends egret.Sprite {
  private mc: egret.MovieClip
  private result = [1, 1]
  public constructor() {
    super()
    this.once(eui.UIEvent.COMPLETE, this.onComplete, this)
  }
  private onComplete() {
    
  }
  public playAction() {
    StageData.soundObj.soundSinglePlay("openmall")
    
    this.x = 550
    this.y = 300
    // var data = RES.getRes('yaoshaizi_png')
    // var txtr = RES.getRes('yaoshaizi_json')
    // var mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr)
    // console.log('mcFactory', mcFactory);
    // var mc = new egret.MovieClip(mcFactory.generateMovieClipData('shaizi'))
    // var mc:egret.MovieClip = MyLibrary.createMovieClipByName("yaoshaizi");

    var name = 'yaoshaizi'
    var spr1: egret.MovieClip = new egret.MovieClip();
    var data = RES.getRes(name + "_json");
    var texture = RES.getRes(name + "_png");
    var mcDataFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data,texture);
    spr1 = new egret.MovieClip(mcDataFactory.generateMovieClipData('shaizi'))

    spr1.width = 120
    spr1.height = 80
    this.mc = spr1

    this.addChild(this.mc)
    // this.mc.gotoAndPlay(1)
    this.mc.play(1)    
    // this.mc.play()      
    this.mc.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
      this.removeChild(this.mc)
      // this.dispatchEvent(new egret.Event('playEnd'))
      const shaizi1 = MyLibrary.createBitmapByName(`Dice1_00${this.result[0]}_png`)
      this.addChild(shaizi1)
      const shaizi2 = MyLibrary.createBitmapByName(`Dice1_00${this.result[1]}_png`)
      shaizi2.x = shaizi1.width + 10
      this.addChild(shaizi2)
      setTimeout(() => {
        this.removeChildren()
        this.parent.removeChild(this)
      }, 2000)
    }, this)
  }
  public setResult(msg) {
    this.result = msg
  }
}
